package com.集合.Collection___.List_;

import java.util.*;

@SuppressWarnings("all")
public class List的三种遍历方式 {
    public static void main(String[] args) {
        /**
         *
         * 1.迭代器iterator
         * 2.增强for循环
         * 3.普通for循环
         *
         * 这些方法对于List的实现子类都通用 例如：
         * List vector = new Vector();
         * LinkedList linkedList = new LinkedList();
         */
        List list = new ArrayList();
        list.add("急急急");
        list.add("hhhh");
        list.add("eeexcsd");



        //1.迭代器iterator
        Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            Object next = iterator.next();
            System.out.println(next);
        }
        System.out.println("======================================");

        //2.增强for循环
        for (Object o : list) {
            System.out.println(o);
        }
        System.out.println("======================================");

        //3.普通for循环
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
        System.out.println("======================================");

    }
}
